package org.afs.gescol.core.service.implementations;

import java.util.List;

import org.afs.gescol.core.dao.interfaces.AppreciationDao;
import org.afs.gescol.core.dao.interfaces.CycleDao;
import org.afs.gescol.core.dao.interfaces.DayDao;
import org.afs.gescol.core.dao.interfaces.HourlyDao;
import org.afs.gescol.core.dao.interfaces.LevelDao;
import org.afs.gescol.core.dao.interfaces.PeriodDao;
import org.afs.gescol.core.dao.interfaces.SchoolClassDao;
import org.afs.gescol.core.dao.interfaces.SeriesDao;
import org.afs.gescol.core.dao.interfaces.TeacherManagmentDao;
import org.afs.gescol.core.dao.interfaces.SubjectManagmentDao;
import org.afs.gescol.core.dao.interfaces.TranchePaymentDao;
import org.afs.gescol.core.dto.LevelCriteria;
import org.afs.gescol.core.dto.SeriesCriteria;
import org.afs.gescol.core.service.interfaces.ReferenceServices;
import org.afs.gescol.core.service.util.MessageKeyUtil;
import org.scub.foundation.framework.base.dto.IdLabelDto;
import org.scub.foundation.framework.base.exception.TechnicalException;
import org.scub.foundation.framework.base.mapping.util.MapperDozerBean;
import org.scub.foundation.framework.base.messagesource.MessageSourceUtil;

public class ReferenceServicesImpl implements ReferenceServices {

    private MessageSourceUtil messageSourceUtil;

    private MapperDozerBean mapperDozerBean;

    private AppreciationDao appreciationDao;

    private CycleDao cycleDao;

    private DayDao dayDao;

    private HourlyDao hourlyDao;

    private LevelDao levelDao;

    private PeriodDao periodDao;

    private SeriesDao seriesDao;

    private SchoolClassDao schoolClassDao;

    private TeacherManagmentDao teacherManagmentDao;

    private SubjectManagmentDao subjectManagmentDao;

    private TranchePaymentDao tranchePaymentDao;

    @Override
    public List<IdLabelDto> getAppreciationByLabel(String label) {
        return mapperDozerBean.mapList(appreciationDao.getAppreciationsByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getCycleByLabel(String label) {
        return mapperDozerBean.mapList(cycleDao.getCyclesByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getDayByLabel(String label) {
        return mapperDozerBean.mapList(dayDao.getDaysByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getHourlyByLabel(String label) {
        return mapperDozerBean.mapList(hourlyDao.getHourlysByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getPeriodByLabel(String label) {
        return mapperDozerBean.mapList(periodDao.getPeriodsByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getSubjectByLabel(String label) {
        return mapperDozerBean.mapList(subjectManagmentDao.getSubjectsByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getTranchePaymentByLabel(String label) {
        return mapperDozerBean.mapList(tranchePaymentDao.getTranchePaymentsByLabel(label), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getLevelByCriteria(LevelCriteria levelCriteria) {
        if (levelCriteria == null) {
            throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_NULL_LEVEL_CRITERIA));
        }
        return mapperDozerBean.mapList(levelDao.getLevelsByCriteria(levelCriteria), IdLabelDto.class);
    }

    @Override
    public List<IdLabelDto> getSeriesByCriteria(SeriesCriteria seriesCriteria) {
        if (seriesCriteria == null) {
            throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_NULL_SERIES_CRITERIA));
        }
        return mapperDozerBean.mapList(seriesDao.getSeriesByCriteria(seriesCriteria), IdLabelDto.class);
    }

    @Override
    public IdLabelDto getSubjectById(Long id) {
        return mapperDozerBean.map(subjectManagmentDao.getSubjectById(id), IdLabelDto.class);
    }

    @Override
    public IdLabelDto getSchoolClassById(Long id) {
        return mapperDozerBean.map(schoolClassDao.getSchoolClassById(id), IdLabelDto.class);
    }

    @Override
    public IdLabelDto getTeacherById(Long id) {
        return mapperDozerBean.map(teacherManagmentDao.getTeacherById(id), IdLabelDto.class);
    }

    /**
     * Set the value of mapperDozerBean.
     * @param mapperDozerBean the mapperDozerBean to set
     */
    public void setMapperDozerBean(MapperDozerBean mapperDozerBean) {
        this.mapperDozerBean = mapperDozerBean;
    }

    /**
     * Set the value of appreciationDao.
     * @param appreciationDao the appreciationDao to set
     */
    public void setAppreciationDao(AppreciationDao appreciationDao) {
        this.appreciationDao = appreciationDao;
    }

    /**
     * Set the value of cycleDao.
     * @param cycleDao the cycleDao to set
     */
    public void setCycleDao(CycleDao cycleDao) {
        this.cycleDao = cycleDao;
    }

    /**
     * Set the value of dayDao.
     * @param dayDao the dayDao to set
     */
    public void setDayDao(DayDao dayDao) {
        this.dayDao = dayDao;
    }

    /**
     * Set the value of hourlyDao.
     * @param hourlyDao the hourlyDao to set
     */
    public void setHourlyDao(HourlyDao hourlyDao) {
        this.hourlyDao = hourlyDao;
    }

    /**
     * Set the value of levelDao.
     * @param levelDao the levelDao to set
     */
    public void setLevelDao(LevelDao levelDao) {
        this.levelDao = levelDao;
    }

    /**
     * Set the value of periodDao.
     * @param periodDao the periodDao to set
     */
    public void setPeriodDao(PeriodDao periodDao) {
        this.periodDao = periodDao;
    }

    /**
     * Set the value of seriesDao.
     * @param seriesDao the seriesDao to set
     */
    public void setSeriesDao(SeriesDao seriesDao) {
        this.seriesDao = seriesDao;
    }

    /**
     * Set the value of schoolClassDao.
     * @param schoolClassDao the schoolClassDao to set
     */
    public void setSchoolClassDao(SchoolClassDao schoolClassDao) {
        this.schoolClassDao = schoolClassDao;
    }

    /**
     * Set the value of teacherManagmentDao.
     * @param teacherManagmentDao the teacherManagmentDao to set
     */
    public void setTeacherManagmentDao(TeacherManagmentDao teacherManagmentDao) {
        this.teacherManagmentDao = teacherManagmentDao;
    }

    /**
     * Set the value of subjectManagmentDao.
     * @param subjectManagmentDao the subjectManagmentDao to set
     */
    public void setSubjectManagmentDao(SubjectManagmentDao subjectManagmentDao) {
        this.subjectManagmentDao = subjectManagmentDao;
    }

    /**
     * Set the value of tranchePaymentDao.
     * @param tranchePaymentDao the tranchePaymentDao to set
     */
    public void setTranchePaymentDao(TranchePaymentDao tranchePaymentDao) {
        this.tranchePaymentDao = tranchePaymentDao;
    }

    /**
     * Set the value of messageSourceUtil.
     * @param messageSourceUtil the messageSourceUtil to set
     */
    public void setMessageSourceUtil(MessageSourceUtil messageSourceUtil) {
        this.messageSourceUtil = messageSourceUtil;
    }

}
